package com.ceshiren.test.houduankaifa.controller;


import org.springframework.web.bind.annotation.*;

@RestController
public class BaseGetController {


    @GetMapping("/first")
//    @RequestMapping(method = RequestMethod.GET,value = "first")
    public String getFirst() {
        return "Hello Spring Boot";
    }

    @GetMapping("/getId/{id}")
    public String getId(@PathVariable String id) {
        return "帖子地址的ID 为 ：" + id;
    }

    @GetMapping("/native")
    public String getNative(@RequestParam("s") String sid) {
        return "这是一个返回地址为 " + sid + " 的内容";
    }

    @GetMapping("/topic/{id}")
    public String getURIWithParam(@PathVariable String id, @RequestParam("s") String sid) {
        return "路径拼接ID为：" + id + "，queryParam 请求参数为：" + sid;
    }

    // 路径上的参数，不可以利用params进行判断，只能是方法中的参数进行判断，而且可以判断多个
    @GetMapping(value = "/topic/{id}", params = {
            "s=88"
    })
    public String getURIWithParam1(@PathVariable String id, @RequestParam("s") String sid) {
        return "路径拼接ID为：" + id + "，queryParam 请求参数为：" + sid + " getURIWithParam1";
    }


    @GetMapping("/default")
    public String getDefaultValue(@RequestParam(defaultValue = "77") String id) {
        return "传入参数的值为：" + id;
    }

    @GetMapping("/getMul/{city}/{year}")
    public String getMulValue(@PathVariable("city") String city, @PathVariable("year") String year,
                              @RequestParam("money") String money, @RequestParam("des") String describe) {
        return " { " + year + " } 年  { " + city + " } 人均 { " + describe + " } 为 { " + money + " } 元";
    }

}
